/*****************************************************************************/
/*                                                                           */
/*    Domino Operation System System Specific Module                         */
/*                                                                           */
/*    Copyright (C) 2013 Laszlo Arvai                                        */
/*                                                                           */
/*    ------------------------------------------------------------------   */
/*    Network JSON serialization/deserialization                             */
/*****************************************************************************/

#ifndef __netJSON_h
#define __netJSON_h

///////////////////////////////////////////////////////////////////////////////
// Includes
#include <krnlString.h>
#include <krnlDateTime.h>

///////////////////////////////////////////////////////////////////////////////
// Types
// callback function pointer for JSON parser
typedef void (*JSONParserCallbackFunction)(dosString in_buffer, dosStringLength in_buffer_length, dosStringLength* inout_pos, dosBool* inout_success, void* in_user_data);

// callback information for JSON parser
typedef struct
{
	dosConstString Key;
	JSONParserCallbackFunction Callback;
} netJSONCallbackInfo;


///////////////////////////////////////////////////////////////////////////////
// Functon prototypes
dosStringLength netJSONAddSeparator(dosString out_buffer, dosStringLength in_buffer_length, dosStringLength in_pos, dosBool* in_add_separator);

void netJSONStart(void);

dosStringLength netJSONObjectStart(dosString out_buffer, dosStringLength in_buffer_length, dosStringLength in_pos, dosConstString in_name);
dosStringLength netJSONObjectEnd(dosString out_buffer, dosStringLength in_buffer_length, dosStringLength in_pos);

dosStringLength netJSONArrayEnd(dosString out_buffer, dosStringLength in_buffer_length, dosStringLength in_pos);
dosStringLength netJSONArrayStart(dosString out_buffer, dosStringLength in_buffer_length, dosStringLength in_pos, dosConstString in_name);

dosStringLength netJSONAddString(dosString out_buffer, dosStringLength in_buffer_length, dosStringLength in_pos, dosConstString in_name, dosString in_string);
dosStringLength netJSONAddWord(dosString out_buffer, dosStringLength in_buffer_length, dosStringLength in_pos, dosConstString in_name, dosWord in_data, dosByte in_field_length, dosByte in_precision, dosByte in_options );
dosStringLength netJSONAddInt32(dosString out_buffer, dosStringLength in_buffer_length, dosStringLength in_pos, dosConstString in_name, dosInt32 in_data, dosByte in_field_length, dosByte in_precision, dosByte in_options );
dosStringLength netJSONAddDateTime(dosString out_buffer, dosStringLength in_buffer_length, dosStringLength in_pos, dosConstString in_name, dosDateTime in_word);

void netJSONParse(dosString in_buffer, dosStringLength in_buffer_length, dosStringLength* inout_pos, dosBool* inout_success, netJSONCallbackInfo in_callback[], void* in_user_data);

#endif